<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    .active{
        background-color: yellow;
    }
</style>
<body>
    <div id="div">
        <div @click="indexNum=key" v-for="(item,key) in dataList" :key="item.id" :class="{active:indexNum===key}">{{item.uname}}</div>
    </div>
    <script src="../vue.js"></script>
    <script>
        const vue = new Vue({
            el: '#div',
            data:{
                indexNum:0
                ,dataList:[{id:1,uname:"京东"},{id:2,uname:"百度"},{id:3,uname:"网易"}]
            },methods:{
                change(value){
                    console.log(value)
                    this.indexNum = value
                    console.log(this.indexNum)
                }
            }
        });
    </script>
</body>
</html>